/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.pedidos.servidor.mb.model;

import br.com.pedidos.servidor.util.HistoricoPedidos;
import java.io.Serializable;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author Weslley
 */
public class HistoricoPedidosModel extends ListDataModel<HistoricoPedidos> implements SelectableDataModel<HistoricoPedidos>, Serializable {

    public HistoricoPedidosModel() {

    }

    public HistoricoPedidosModel(List<HistoricoPedidos> data) {
        super(data);
    }

    @Override
    public Object getRowKey(HistoricoPedidos hp) {
        return hp.getIdentificador();
    }

    @Override
    public HistoricoPedidos getRowData(String rowKey) {
        List<HistoricoPedidos> hps = (List<HistoricoPedidos>) getWrappedData();

        for (HistoricoPedidos hp : hps) {
            if (hp.getIdentificador() == Integer.parseInt(rowKey)) {
                return hp;
            }
        }

        return null;
    }
}
